<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('材料申请单列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
<!--                        <li>-->
<!--                            <label>材料类型：</label>-->
<!--                            <input type="text" name="matTypes"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label>材料分类：</label>-->
<!--                            <input type="text" name="matClassifications"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label>材料数据：</label>-->
<!--                            <input type="text" name="matDatas"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label>材料详情：</label>-->
<!--                            <input type="text" name="matDetailss"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label>材料数量：</label>-->
<!--                            <input type="text" name="matNumbers"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label>申请人：</label>-->
<!--                            <input type="text" name="mPeoples"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label>状态：</label>-->
<!--                            <select name="mStatus">-->
<!--                                <option value="">所有</option>-->
<!--                            </select>-->
<!--                        </li>-->
<!--                        <li class="select-time">-->
<!--                            <label>创建时间：</label>-->
<!--                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginMMtime]"/>-->
<!--                            <span>-</span>-->
<!--                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endMMtime]"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label>审批意见：</label>-->
<!--                            <input type="text" name="mOpinions"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label>项目外键：</label>-->
<!--                            <input type="text" name="mId"/>-->
<!--                        </li>-->
                        <li>
                            <label>项目名称：</label>
                            <input type="text" name="pName"/>
                        </li>
                        <li class="select-time">
                            <label>创建时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <!--            <div class="btn-group-sm" id="toolbar" role="group">-->
        <!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ruoyi:requisitiones:add">-->
        <!--                    <i class="fa fa-plus"></i> 添加-->
        <!--                </a>-->
        <!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:requisitiones:edit">-->
        <!--                    <i class="fa fa-edit"></i> 修改-->
        <!--                </a>-->
        <!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:requisitiones:remove">-->
        <!--                    <i class="fa fa-remove"></i> 删除-->
        <!--                </a>-->
        <!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:requisitiones:export">-->
        <!--                    <i class="fa fa-download"></i> 导出-->
        <!--                </a>-->
        <!--            </div>-->
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('ruoyi:requisitiones:edit')}]];
    var removeFlag = [[${@permission.hasPermi('ruoyi:requisitiones:remove')}]];
    var creadFlag = [[${@permission.hasPermi('ruoyi:requisitiones:add')}]];
    var prefixs = ctx + "ruoyi/requisitionesVerify";
    var prefix = ctx + "system/building";
    //审批状态字典
    var mStatus = [[${@dict.getType('mate_status')}]];
    $(function(){
        var options = {
            url: prefix + "/list",
            createUrl: prefixs + "/add/{id}",
            exportUrl: prefix + "/export",
            removeUrl: prefixs + "/remove",
            updateUrl: prefixs + "/edit/{id}",
            modalName:"",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            detailView: true,
            onExpandRow: function (index, row, $building) {
                initChildTable(index, row, $building);
            },

            columns: [{
                checkbox: true
            },
                {
                    field: 'pId',
                    title: '项目id',
                    visible: false
                },
                {
                    field: 'pName',
                    title: '项目名称'
                },
                {
                    field: 'pTime',
                    title: '项目日期'
                },
                {
                    field: 'pFounder',
                    title: '项目经理'
                }
            ]
        };
        $.table.init(options);
    });
    initChildTable = function (index, row, $building) {
        var childTable = $building.html('<table style="table-layout:fixed"></table>').find('table');
        $(childTable).bootstrapTable({
            url: prefixs  + "/lists",
            method: 'post',
            sidePagination: "server",
            contentType: "application/x-www-form-urlencoded",
            queryParams: {
                mId:row.pId
            },
            columns: [
                // {
                //     checkbox: true
                // },
                {
                    field: 'mMid',
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'matTypes',
                    title: '材料类型'
                },
                {
                    field: 'matClassifications',
                    title: '材料分类'
                },
                {
                    field: 'matDatas',
                    title: '材料数据'
                },
                {
                    field: 'matDetailss',
                    title: '材料详情'
                },
                {
                    field: 'matNumbers',
                    title: '材料数量'
                },
                {
                    field: 'mPeoples',
                    title: '申请人'
                },
                {
                    field: 'mStatus',
                    title: '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(mStatus, value);
                    }
                },
                {
                    field: 'mMtime',
                    title: '创建时间'
                },
                {
                    field: 'mOpinions',
                    title: '审批意见'
                },
                {
                    field: 'mId',
                    title: '项目外键',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.mStatus==1){
                            actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="consent(\'' + row.mMid + '\')"><i class="fa fa-user"></i> 通过</a> ');
                            actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mMid + '\')"><i class="fa fa-edit"></i>驳回</a> ');
                        }
                        return actions.join('');
                    }
                }
            ]
        });
    };
    function consent(mMid) {

        $.modal.confirm("确认要通过申请吗?", function() {
            var url = prefixs + "/consent";
            var data = { "mMid": mMid };
            $.operate.submit(url, "post", "json", data);
        });
    }
</script>
</body>
</html>